# Generated by Django 2.2.24 on 2022-01-19 16:55

from django.db import migrations, models

urls = {}


def _save_urls(apps, schema_editor):
    MonthlyCantonalValidationUrl = apps.get_model(
        "salary", "MonthlyCantonalValidationUrl"
    )
    urls.update({obj.id: obj.url for obj in MonthlyCantonalValidationUrl.objects.all()})


def _add_translated_urls(apps, schema_editor):
    MonthlyCantonalValidationUrlTranslation = apps.get_model(
        "salary", "MonthlyCantonalValidationUrlTranslation"
    )
    for master_id, url in urls.items():
        MonthlyCantonalValidationUrlTranslation.objects.filter(
            master_id=master_id
        ).update(url=url)


class Migration(migrations.Migration):
    dependencies = [
        ("salary", "0016_monthlycantonalvalidationurltranslation_label"),
    ]

    operations = [
        migrations.RunPython(_save_urls, migrations.RunPython.noop),
        migrations.RemoveField(
            model_name="monthlycantonalvalidationurl",
            name="url",
        ),
        migrations.AddField(
            model_name="monthlycantonalvalidationurltranslation",
            name="url",
            field=models.URLField(default="", verbose_name="URL"),
            preserve_default=False,
        ),
        migrations.RunPython(_add_translated_urls, migrations.RunPython.noop),
    ]
